package com.kfm.jdbc.day0325;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 数据库category表对应的实体类
 */
public class Category {

    private Integer no;
    private String name;

    public static class CategoryRecover implements Recover<Category> {

        @Override
        public List<Category> recover(ResultSet set) throws SQLException {
            List<Category> list = new ArrayList<>();
            while (set.next()) {
                // 封装成Goods对象
                Category category = new Category();
                category.setNo(set.getInt(1));
                category.setName(set.getString(2));
                list.add(category);
            }
            return list;
        }
    }

    @Override
    public String toString() {
        return "Category{" +
                "no=" + no +
                ", name='" + name + '\'' +
                '}';
    }

    public Integer getNo() {
        return no;
    }

    public void setNo(Integer no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
